﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _02.Strategy
{
    public partial class Form1 : Form
    {
        double total = 0.0d;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            cbxType.Items.AddRange(new string[] { "正常收费", "满300返100", "打8折" });
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            CashContext cc = new CashContext(cbxType.SelectedItem.ToString());
            double totalPrices = cc.GetResult(double.Parse(txtPrice.Text) * double.Parse(txtNum.Text));
            total += totalPrices;
            lbxList.Items.Add("单价：" + txtPrice.Text + " 数量：" + txtNum.Text + " 合计：" + totalPrices.ToString());
            lblResult.Text = total.ToString();
        }
    }
}
